package com.santoker.user.service.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 *  配置druid需要的配置类，引入application.properties文件中以spring.datasource开头的信息
 *  因此需要在application.properties文件中配置相关信息。
 */
@Configuration
@ServletComponentScan
public class DruidConfig {

    /**
     * 加载时读取指定的配置信息,前缀为spring.datasource.druid
     *
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource.druid")
    public DataSource druidDataSource(){
        return new DruidDataSource();
    }

}
